<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 店铺审核模型
 * author : wucan
 * date : 2017-10-27
 */
class ShopAudit extends Model
{
    //
    protected $table = 'shop_audit';

    public $timestamps = false;

    protected $primaryKey = 'audit_id';

    protected $fillable = [
        'audit_id',
        'user_id',
        'cate_id',
        'province_id',
        'city_id',
        'area_id',
        'business_id',
        'shop_name',
        'logo',
        'photo',
        'cuisine_photo',
        'tel',
        'addr',
        'lng',
        'lat',
        'note',
        'pid',
        'name',
        'organization_code',
        'pic',
        'shop_id',
        'audit',
        'create_time',
        'create_ip',
        'audit_user',
        'finish_ip',
        'finish_time',
        'business_date',
        'business_type',
        'business_time',
        'tags',
        'administrator_id',
        'attr_id',
        'rate',
        'logo_oss',
        'photo_oss',
        'cuisine_photo_oss',
        'pic_oss',
    ];

     //定义修改字段（将tags的值转为数组展示）
    protected $casts = ['pic','logo','photo','cuisine_photo'];

    //创建访问器
    public function getPicAttribute($value)
    {
        return \App\Library\HandleFile::handleFilePath($value,$this->pic_oss);
    }

    public function getLogoAttribute($value)
    {
        return \App\Library\HandleFile::handleFilePath($value,$this->logo_oss);
    }

    public function getPhotoAttribute($value)
    {
        return \App\Library\HandleFile::handleFilePath($value,$this->photo_oss);
    }

    public function getCuisinePhotoAttribute($value)
    {
        return \App\Library\HandleFile::handleFilePath($value,$this->cuisine_photo_oss);
    }
}
